package com.example.waibao.dao;


import com.example.waibao.entity.box;
import com.example.waibao.entity.task;
import com.example.waibao.entity.task_review;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface taskMapper {


    @Update("update task_review set status=#{status} where id=#{id}")
    void solve_task_review(task_review taskReview);

    @Insert("insert into rank_score_detail(score_time,add_score,task_id,user_id) values(#{score_time},#{add_score},#{task_id},#{user_id})")
    void add_score_detail(Date score_time, int add_score, int task_id, int user_id);

    @Update("update rank_score_sum set sum_score=sum_score+#{sum_score},last_incom_time = #{last_incom_time}  where user_id=#{user_id}")
    void update_score_sum(int user_id, int sum_score, Date last_incom_time);

    @Update("update rank_speciality_score_sum set sum_score=sum_score+#{sum_score},last_incom_time = #{last_incom_time}  where speciality_id = " +
            "(select speciality_id from user where id = #{id})")
    void update_speciality_score(int sum_score, int id, Date last_incom_time);

    @Update("update rank_score_sum set sum_score=sum_score+5 where user_id=#{user_id}")
    void update_student_level(int user_id);

    @Insert("insert into box(blind_box,school_id) values(#{blind_box},#{school_id})")
    void set_blind_box(box box);

    @Select("select * from box where school_id = #{school_id}")
    List<box> get_blind_box(int school_id);

    @Delete("delete from box where id = #{id}")
    void delete_blind_box(int id);

    @Select("select blind_box from box where school_id = #{school_id}")
    List<String> get_box(int school_id);

    @Update("update user set head_have = 1 where id = #{id}")
    void update_head_heaver(int id);

    @Select("select * from rank_score_detail rsd left join task t on rsd.task_id=t.id where rsd.user_id = #{user_id}")
    List<task> get_student_process1(int user_id);

    @Select("select * from task where speciality_id = (select speciality_id from user where id = #{id}) or speciality_id = 0 and school_id = #{school_id}")
    List<task> get_student_process2(int id,int school_id);
}
